package com.share.shareplatform.util.check;


import com.share.shareplatform.pojo.Shop;
import com.share.shareplatform.util.Result;

public class ShopCheck {

    public static Result checkNameFail(int n){
        if(n==1){
            return Result.getInstance(505,"店名不能为空");
        }else if(n==2){
            return Result.getInstance(505,"店名太长");
        }
        return Result.getInstance(505,"未知错误");
    }

    /*
     * return 0 表示正确
     *        1 为空
     *        2 太长
     * */
    public static int checkName(String s){

        if(s==null||s.trim().equals("")){
            return 1;
        }
        if(s.trim().length()>20){
            return 2;
        }
        return 0;
    }

    public static Result checkIntroduceFail(int n){
        if(n==1){
            return Result.getInstance(505,"介绍不能为空");
        }else if(n==2){
            return Result.getInstance(505,"介绍太长");
        }
        return Result.getInstance(505,"未知错误");
    }

    /*
     * return 0 表示正确
     *        1 为空
     *        2 太长
     * */
    public static int checkIntroduce(String s){

        if(s==null||s.trim().equals("")){
            return 1;
        }
        if(s.trim().length()>200){
            return 2;
        }
        return 0;
    }


    public static final int INIT_VISIT=0;
    public static final double INIT_CREDIT=5.0;
    public static final int INIT_DEAL=0;

    public static void setUnAlter(Shop shop){
        shop.setVisit(INIT_VISIT);
        shop.setCredit(INIT_CREDIT);
        shop.setDeal(INIT_DEAL);
    }

}
